<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../vue.js"></script>
    <script src="../vue-router.js"></script>
    <style>
        .box {
            width: 800px;
            height: 400px;
            margin: 10px auto;
            /* border: 1px solid black; */
            box-shadow: 0px 0px 10px;
            border-radius: 10px;
            position: relative;
        }
        
        .cont {
            height: 400px;
            width: 800px;
            line-height: 100%;
            text-align: center;
        }
        
        .nav {
            position: absolute;
            bottom: -100px;
            /* border: 1px solid black; */
            width: 320px;
            height: 50px;
            left: calc(50% - 160px);
            display: flex;
            justify-content: space-between;
            box-shadow: 0px 0px 10px;
            border-radius: 10px;
        }
        
        .nav a {
            text-decoration: none;
            display: inline-block;
            width: 100px;
            height: 50px;
            text-align: center;
            line-height: 50px;
            font-size: 20px;
            font-weight: bold;
            border-radius: 10px;
        }
        
        .router-link-exact-active,
        .router-link-active {
            background-color: red;
            color: white;
        }
    </style>
</head>

<body>
    <div class="app">
        <h1>{{title}}</h1>
        <div class="box">
            <div class="cont">
                <router-view></router-view>
            </div>
            <div class="nav">
                <router-link to="/Home">首页</router-link>
                <router-link to="/Find">发现页</router-link>
                <router-link to="/User">个人中心</router-link>
            </div>
        </div>
    </div>

    <template id="home">
        <div>
            <h1>{{content}}</h1>
            <img :src="imgsrc" alt="">
        </div>
    </template>
    <template id="find">
        <div>
            <h1>{{content}}</h1>
            
        </div>
    </template>
    <template id="user">
        <div>
            <h1>{{content}}</h1>
        </div>
    </template>

    <script>
        //定义路由组件
        const Home = {
            template: '#home',
            data() {
                return {
                    content: "我是首页",
                    imgsrc: "../day01/images/1642131151272.jpg"
                }
            },
        }
        const Find = {
            template: '#find',
            data() {
                return {
                    content: "我是发现页"
                }
            },
        }
        const User = {
                template: '#user',
                data() {
                    return {
                        content: "我是个人中心"
                    }
                },
            }
            //定义一些路由
        const routers = [{
                path: "/Home",
                component: Home
            }, {
                path: "/Find",
                component: Find
            }, {
                path: "/User",
                component: User
            }, ]
            //创建实例化路由
        const router = new VueRouter({
            routes: routers
        })
        const vm = new Vue({
            //挂载在根实例上
            router,
            data: {
                title: "路由配置"
            }
        }).$mount(".app")
    </script>
</body>

</html>